css: Return GArrays from shorthand parsing
authorBenjamin Otte <otte@redhat.com>
Wed, 25 Jan 2012 17:28:26 +0000 (18:28 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 25 Jan 2012 18:05:33 +0000 (19:05 +0100)
GValueArray is deprecated now.

gtk/gtkcssprovider.c
gtk/gtkcssshorthandproperty.c

index 5285d29a3f9ebf93772dc1f8bb01f11c9f0b38f8..7d2f18329d9941b1ae3f9a1e1d658024ee098d1d 100644 (file)
@@ -1194,17 +1194,18 @@ gtk_css_ruleset_add (GtkCssRuleset    *ruleset,
   if (GTK_IS_CSS_SHORTHAND_PROPERTY (prop))
     {
       GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (prop);
-      GValueArray *array = g_value_get_boxed (&value->value);
+      GArray *array = g_value_get_boxed (&value->value);
       guint i;
 
       for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
         {
           GtkCssStyleProperty *child = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
+          const GValue *sub = &g_array_index (array, GValue, i);
           PropertyValue *val;
           
           val = property_value_new (value->section);
-          g_value_init (&val->value, G_VALUE_TYPE (g_value_array_get_nth (array, i)));
-          g_value_copy (g_value_array_get_nth (array, i), &val->value);
+          g_value_init (&val->value, G_VALUE_TYPE (sub));
+          g_value_copy (sub, &val->value);
           gtk_css_ruleset_add (ruleset, GTK_STYLE_PROPERTY (child), val);
         }
       property_value_free (value);
index 303376e98625bf1b17cc4bbfb77ac09e97ab84d3..c74ddaea07bac6312ad273f02d11d1a4907c1ad0 100644 (file)
@@ -91,12 +91,12 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
                                         GFile            *base)
 {
   GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
-  GValueArray *array;
+  GArray *array;
   guint i;
 
-  array = g_value_array_new (shorthand->subproperties->len);
-  for (i = 0; i < shorthand->subproperties->len; i++)
-    g_value_array_append (array, NULL);
+  array = g_array_new (FALSE, TRUE, sizeof (GValue));
+  g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
+  g_array_set_size (array, shorthand->subproperties->len);
 
   if (_gtk_css_parser_try (parser, "initial", TRUE))
     {
@@ -105,7 +105,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
        */
       for (i = 0; i < shorthand->subproperties->len; i++)
         {
-          GValue *val = g_value_array_get_nth (array, i);
+          GValue *val = &g_array_index (array, GValue, i);
           g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
           g_value_set_enum (val, GTK_CSS_INITIAL);
         }
@@ -120,14 +120,14 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
        */
       for (i = 0; i < shorthand->subproperties->len; i++)
         {
-          GValue *val = g_value_array_get_nth (array, i);
+          GValue *val = &g_array_index (array, GValue, i);
           g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
           g_value_set_enum (val, GTK_CSS_INHERIT);
         }
     }
-  else if (!shorthand->parse (shorthand, array->values, parser, base))
+  else if (!shorthand->parse (shorthand, (GValue *) array->data, parser, base))
     {
-      g_value_array_free (array);
+      g_array_free (array, TRUE);
       return FALSE;
     }
 
@@ -136,14 +136,14 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
    * XXX: Is the default always initial or can it be inherit? */
   for (i = 0; i < shorthand->subproperties->len; i++)
     {
-      GValue *val = g_value_array_get_nth (array, i);
+      GValue *val = &g_array_index (array, GValue, i);
       if (G_IS_VALUE (val))
         continue;
       g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
       g_value_set_enum (val, GTK_CSS_INITIAL);
     }
 
-  g_value_init (value, G_TYPE_VALUE_ARRAY);
+  g_value_init (value, G_TYPE_ARRAY);
   g_value_take_boxed (value, array);
   return TRUE;
 }